﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 象棋_封_
{
    public partial class Main : Form
    {
        Chess[][] checkerboard;
        Time blue;
        Time red;
        public Main()
        {
            InitializeComponent();
            this.DoubleBuffered = true;
            Chess.Clearground(this, ref checkerboard);
            LB_redtime.Text = "";
            LB_bluetime.Text = "";
            blue = new Time(timer_blue, LB_bluetime);
            red = new Time(timer_red, LB_redtime);
            red.t.Start();
        }
        private void pictureBox_Click(object sender, EventArgs e)
        {
            if (Chess.chosen)
            {
                if (Chess.Chozen_dispose(sender, checkerboard))
                {
                    red.t.Stop();
                    red.clear();
                    blue.t.Stop();
                    blue.clear();
                }
                if (Chess.control_side == player_type.red)
                {
                    red.t.Start();
                    blue.clear();
                    blue.t.Stop();
                }
                else
                {
                    blue.t.Start();
                    red.clear();
                    red.t.Stop();
                }
            }
            else
                Chess.Nochozen_dispose(sender, checkerboard);
        }

        private void timer_blue_Tick(object sender, EventArgs e)
        {
            this.LB_bluetime.Text = blue.outtime();
        }

        private void timer_red_Tick(object sender, EventArgs e)
        {
            this.LB_redtime.Text = red.outtime();
        }
    }
}
    